<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>2-06 矩形1</title>
</head>
<body>
  <canvas id="c" width="300" height="300" style="border: 1px solid #ccc;"></canvas>

  <script>
    const context = document.getElementById('c')
    const ctx = context.getContext('2d')

    // 绘制矩形
    ctx.moveTo(50, 50)
    ctx.lineTo(200, 50)
    ctx.lineTo(200, 120)
    ctx.lineTo(50, 120)
    ctx.lineTo(50, 50)

    ctx.stroke()
  </script>
</body>
</html>